<!DOCTYPE html>
<html>
<head>
<title>代码生成器</title>
<#include "/header.html">
</head>
<div id="rrapp">
	<div>书柜编号：<d id="rfid_code_d"></d>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;投放地址：<d id="shelf_address_d"></d></datalist></div><br/>
	<div>书格数量：<d id="shelf_grid_num_d"></d>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前实际书籍数量：<d id="current_count_d"></d></div>
	<hr/>
	<button  value="01" id="1" class="bookGrid">书柜1</button>
	<button  value="02" id="2" class="bookGrid">书柜2</button>
	<button  value="03" id="3" class="bookGrid">书柜3</button>
	<button  value="04" id="4" class="bookGrid">书柜4</button>
	<button  value="05" id="5" class="bookGrid">书柜5</button>
	<button  value="06" id="6" class="bookGrid">书柜6</button>
	<button  value="07" id="7" class="bookGrid">书柜7</button>
	<button  value="08" id="8" class="bookGrid">书柜8</button>
	<button onclick="refreshGrid()">重新盘点</button>
	<button onclick="unlockGrid()">打开书格</button>
	<button onclick="restartShelf()">书柜重启</button>
	<button onclick="checkShelfAll()">整柜盘点</button>
    <table id="jqGrid"></table>
    <div id="jqGridPager"></div>
</div>
<script type="text/javascript" src="${request.contextPath}/statics/js/modules/operation/book-shelf-monitoring.js?_${.now?long}"></script>
<script type="text/javascript">
function getBookShelfInfo(){
	var data = {"code":code}
	$.ajax({
		url : baseURL + 'operation/bookShelf/getBookShelfInfo',
		type : 'POST',
		contentType : "application/json; charset=utf-8",
		data : JSON.stringify(data),
		dataType : 'json',
		success : function(result) {
			if (result.detail != null) {
				document.getElementById("rfid_code_d").innerHTML=result.detail.code;
				document.getElementById("shelf_address_d").innerHTML=result.detail.cashAddress;
				document.getElementById("shelf_grid_num_d").innerHTML=result.detail.bookGridCount;
				document.getElementById("current_count_d").innerHTML=result.detail.currentCount;
			} else {
				layer.msg(message, {
					icon : -1
				});
			}
		}
	});
}
getBookShelfInfo();
$('.bookGrid').click(function(){
    var bookGridCodePostfix = $(this).attr('value');
    sessionStorage.bookGridCodePostfix = bookGridCodePostfix;
    vm.query(bookGridCodePostfix);
});
function refreshGrid(){
	var data = {"bookgridCode":gridCode};
	$.ajax({
		url : baseURL + "operation/bookShelf/getBookGridInfoRefresh",
		type : 'POST',
		contentType : "application/json; charset=utf-8",
		data : JSON.stringify(data),
		dataType : 'json',
		success : function(result) {
			if (result.detail != null) {
				layer.msg(result.detail.message, {
					icon : -1
				});
				if(result.detail.code==100){
					vm.query(sessionStorage.bookGridCodePostfix);
				}
			} else {
				layer.msg(message, {
					icon : -1
				});
			}
		}
	});
};
function unlockGrid(){
	//unlock('operation/bookShelf/unlock',jsonData,'开柜成功',sessionStorage.bookGridCodePostfix);
	var jsonData = {"bookgridCode":gridCode};
	$.ajax({
		url : baseURL + 'operation/bookShelf/unlock',
		type : 'POST',
		contentType : "application/json; charset=utf-8",
		data : JSON.stringify(jsonData),
		dataType : 'json',
		success : function(result) {
			if (result.detail != null) {
				layer.msg(result.detail.message, {
					icon : -1
				});
			} else {
				layer.msg(message, {
					icon : -1
				});
			}
			/* var textHint = document.getElementById('hint');
    		textHint.value=textHint.value+'\n'+postfix+"号柜请求开柜。"
    		textHint.value = textHint.value+'\n'+result.detail.message; */
		}
	});
}
function restartShelf(){
	var jsonData = {"bookshelfCode":code};
	$.ajax({
		url : baseURL + 'operation/bookShelf/restart',
		type : 'POST',
		contentType : "application/json; charset=utf-8",
		data : JSON.stringify(jsonData),
		dataType : 'json',
		success : function(result) {
			if (result.detail != null) {
				layer.msg(result.detail.message, {
					icon : -1
				});
			} else {
				layer.msg(message, {
					icon : -1
				});
			}
		}
	});
}
function checkShelfAll(){
	var jsonData = {"bookshelfCode":code};
	$.ajax({
		url : baseURL + 'operation/bookShelf/checkGridAll',
		type : 'POST',
		contentType : "application/json; charset=utf-8",
		data : JSON.stringify(jsonData),
		dataType : 'json',
		success : function(result) {
			if (result.detail != null) {
				layer.msg(result.detail.message, {
					icon : -1
				});
				if(result.detail.code==100){
					vm.query(sessionStorage.bookGridCodePostfix);
				}
			} else {
				layer.msg(message, {
					icon : -1
				});
			}
		}
	});
}
</script>
</html>